package org.example.calc;


import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

import java.io.IOException;

public class Calc {
    public static void main(String[] args) throws IOException {
        ANTLRInputStream input = new ANTLRInputStream("1+1\n");
        MyExprLexer lexer = new MyExprLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        MyExprParser parser = new MyExprParser(tokens);
        ParseTree tree = parser.prog();

        EvalVisitor visitor = new EvalVisitor();
        Integer visit = visitor.visit(tree);

        System.out.printf("value:"+visit);
        System.out.println(tree.toStringTree(parser));

    }
}
